Skip to main content

Managing Tags and Custom Fields

Tags and custom fields are powerful tools for organizing and adding metadata to your videos. This guide will walk you through the process of managing tags and custom fields for videos using the Teyuto API.

Managing Tags

Creating a Tag

To create a new tag:

  1. Use the POST /tags endpoint
  2. Set up your request headers:
    Content-Type: application/x-www-form-urlencoded
    Accept: application/json
    Authorization: YOUR_API_KEY
  3. In the request body, include:
    • title: The name of the tag
    • description: A description of the tag
    • privacy: The privacy setting (e.g., "hidden", "public", "registered")

Example cURL request:

curl -X POST "https://api.teyuto.tv/v2/tags" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=NewTag&description=This is a new tag&privacy=public"

Editing a Tag

To edit an existing tag:

  1. Use the PATCH /tags/{id} endpoint
  2. Replace {id} with the tag ID
  3. In the request body, include the fields you want to update:
    • title: The new name of the tag
    • hidden: Set to "true" to hide the tag, "false" to make it visible

Example cURL request:

curl -X PATCH "https://api.teyuto.tv/v2/tags/12345" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=UpdatedTag&hidden=false"

Deleting a Tag

To delete a tag:

  1. Use the DELETE /tags/{id} endpoint
  2. Replace {id} with the tag ID

Example cURL request:

curl -X DELETE "https://api.teyuto.tv/v2/tags/12345" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"

Applying Tags to Videos

When creating or updating a video, you can apply tags using the tag_ids[] parameter. This is an array of tag IDs that you want to associate with the video.

Example (when creating a new video):

curl -X POST "https://api.teyuto.tv/v2/videos/vod" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=My Video&description=A great video&tag_ids[]=123&tag_ids[]=456"

Managing Custom Fields

Custom fields allow you to add additional metadata to your videos.

Creating a Custom Field

To create a new custom field for videos:

  1. Use the POST /customfields/videos endpoint
  2. In the request body, include:
    • key: The unique identifier for the custom field
    • label: The display name for the custom field
    • show: Set to "true" to make the field visible
    • order: The display order of the field

Example cURL request:

curl -X POST "https://api.teyuto.tv/v2/customfields/videos" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "key=director&label=Director&show=true&order=1"

Editing a Custom Field

To edit an existing custom field:

  1. Use the PATCH /customfields/videos/{key} endpoint
  2. Replace {key} with the custom field's key
  3. In the request body, include the fields you want to update

Example cURL request:

curl -X PATCH "https://api.teyuto.tv/v2/customfields/videos/director" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "label=Film Director&show=true&order=2"

Deleting a Custom Field

To delete a custom field:

  1. Use the DELETE /customfields/videos/{key} endpoint
  2. Replace {key} with the custom field's key

Example cURL request:

curl -X DELETE "https://api.teyuto.tv/v2/customfields/videos/director" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"

Using Custom Fields with Videos

When creating or updating a video, you can include custom field data in the request. The API documentation doesn't specify exactly how to do this, but typically it would be included in the request body, possibly as a JSON object.

Best Practices

  1. Consistent Tagging: Develop a consistent tagging strategy to make it easier to organize and search for videos.

  2. Meaningful Custom Fields: Create custom fields that add valuable metadata to your videos, such as director, genre, or release date.

  3. Regular Cleanup: Periodically review and clean up unused tags and custom fields to keep your system organized.

  4. API Key Security: Always keep your API key secure and never expose it in client-side code.

  5. Error Handling: Implement proper error handling in your code to manage API response errors gracefully.

By effectively using tags and custom fields, you can enhance the organization and searchability of your video content on the Teyuto platform.